package com.zw.yzk.kabu.data.repository;


import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.AtUserEntity;
import com.zw.yzk.kabu.data.network.entity.Entity;
import com.zw.yzk.kabu.data.network.service.AtUserService;
import com.zw.yzk.kabu.data.network.service.AuthCoserService;
import com.zw.yzk.kabu.data.network.task.AthUserTask;
import com.zw.yzk.kabu.data.network.task.AuthCoserTask;
import com.zw.yzk.kabu.data.network.task.Task;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2017/1/4.
 */

public class AuthCoserRepository extends CommonRepository {

    @Inject
    public AuthCoserRepository() {
    }

    @Override
    protected Observable connectServer(Task task) {
        AuthCoserService service = ServiceGenerator.createService(AuthCoserService.class);
        AuthCoserTask uTask = (AuthCoserTask) task;
        return service.auth(uTask.userId, uTask.accessToken, uTask.name, uTask.id);
    }

    @Override
    protected Func1<Entity, Observable> getServerData() {
        return new Func1<Entity, Observable>() {
            @Override
            public Observable call(Entity entity) {
                return Observable.just(entity);
            }
        };
    }

}
